{extend name="/fool" /}
{block name="css"}
<link rel="stylesheet" href="/css/admin/bill.css">
<style>
    #title_one{
        font-size: 15px;
        line-height: 30px;
        border-bottom: 1px solid rgba(0,0,0,0.5);
    }
    #title_two{
        margin-bottom: 100px;
    }
    #title_two li{
        width:30vw;
        float: left;
    }
    .title_two_title{
        font-size: 16px;
        line-height: 50px;
    }
    .title_two_num{
        font-size: 18px;
    }
    #page{
        position: relative;
        display: inline-block;
        left:30%;
        margin-left:-50px;
        padding:50px 0;
    }
</style>
{/block}
{block name="menu_content"}
<div style="width:96vw;margin-left: 2vw;">
    <div id="one">
        <form class="layui-form" action="" method="post">
            <ul>
                <li style="margin-bottom: 20px;">
                    {if isset($bill)}
                    {if $bill == 1}
                    <button type="button" style="border-color: #44A1FF;color:#44A1FF;" class="ri layui-btn layui-btn-primary">日汇总</button>
                    <button type="button" style="color:#c7c7c7;" class="yue layui-btn layui-btn-primary">月汇总</button>
                    {else}
                    <button type="button" style="color:#c7c7c7;" class="ri layui-btn layui-btn-primary">日汇总</button>
                    <button type="button" style="border-color: #44A1FF;color:#44A1FF;" class="yue layui-btn layui-btn-primary">月汇总</button>
                    {/if}
                    {else}
                    <button type="button" style="border-color: #44A1FF;color:#44A1FF;" class="ri layui-btn layui-btn-primary">日汇总</button>
                    <button type="button" style="color:#c7c7c7;" class="yue layui-btn layui-btn-primary">月汇总</button>
                    {/if}
                </li>
                <li>
                    <div class="layui-inline">
                        {if isset($bill)}
                        {if $bill == 1}
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="test11" placeholder="2019-12-20">
                        </div>
                        {else}
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="test3" placeholder="2019-11">
                        </div>
                        {/if}
                        {/if}
                    </div>
                    <button type="button" class="dc layui-btn layui-btn-normal">导出表单</button>
                </li>
            </ul>
        </form>
    </div>
    <div>
        <table>
            <tr>
                <th>序号</th>
                <th>结算时间</th>
                <th>收入</th>
                <th>支出</th>
                <th>结算</th>
                <th>当前总收益</th>
                <th class="last">操作</th>
            </tr>
            {if isset($list)}
            {foreach $list as $k=>$v}
            <tr class="list">
                <td>{$v.id}</td>
                <td>{$v.time}</td>
                <td>{$v.sr}</td>
                <td>{$v.zc}</td>
                <td>{$v.settlement}</td>
                <td>{$v.revenue}</td>
                <td>
                    <button sid="{$v.id}" type="button" class="mx layui-btn">详情</button>
                    <button sid="{$v.id}" type="button" class="viewbu layui-btn">明细</button>
                </td>
            </tr>
            {/foreach}
            {/if}
        </table>
        <div id="page">
            {if isset($list)}
            {$page|raw}
            {/if}
        </div>
    </div>
</div>
<script>
    $(".yue").click(function(){
        location.href = "{:url('bill',['id'=>'7','index'=>'1','bill'=>'2'])}";
    })
    $(".ri").click(function(){
        location.href = "{:url('bill',['id'=>'7','index'=>'1','bill'=>'1'])}";
    })
    $(".dc").click(function(){
        "{if isset($bill)}"
        "{if $bill == 1}"
        var time = $("#test11").val();
        var url = "{:url('dc',['bill'=>'1'])}" + '&time=' + time;
        location.href = url;
        "{else}"
        var time = $("#test3").val();
        var url = "{:url('dc',['bill'=>'2'])}" + '&time=' + time;
        location.href = url;
        "{/if}"
        "{else}"
        var time = $("#test11").val();
        var url = "{:url('dc',['bill'=>'1'])}" + '&time=' + time;
        location.href = url;
        "{/if}"
    })
    layui.use('form', function(){
        var form = layui.form;

        //监听提交
        form.on('submit(formDemo)', function(data){
            layer.msg(JSON.stringify(data.field));
            return false;
        });
    });
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        //执行一个laydate实例
        //年月选择器
        laydate.render({
            elem: '#test3'
            ,type: 'month'
        });
        laydate.render({
            elem: '#test11'
            ,format: 'yyyy-MM-dd'
        });
    });
    $(".viewbu").click(function(){
        var id = $(this).attr('sid');
        "{if $bill == 1}"
        var url = "{:url('billview',['id'=>'7','index'=>'1'])}" + '&view=' + '4' + '&battery_order=' + id;
        "{else}"
        var url = "{:url('billview',['id'=>'7','index'=>'1'])}" + '&view=' + '4' + '&battery_orderyue=' + id;
        "{/if}"
        location.href = url;
    })
    $(".mx").click(function () {
        var id = $(this).attr('sid');
        "{if $bill == 1}"
        var url = "{:url('view',['id'=>'7','index'=>'1','view'=>5,'bill'=>'1'])}" + '&sid=' + id;
        "{else}"
        var url = "{:url('view',['id'=>'7','index'=>'1','view'=>5,'bill'=>'2'])}" + '&sid=' + id;
        "{/if}"
        location.href = url;
    })
    layui.use('laypage', function(){
        var laypage = layui.laypage;
        //执行一个laypage实例
        laypage.render({
            elem: 'page'
            ,count: "{$count}"
            ,curr:"{$curl}"
            ,last:"{$groups}"
            ,limit:"{$limit}"
            ,layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
            ,jump: function(obj,first){
                console.log(obj)
                if(!first){
                    var url = "{:url('index',['id'=>5,'index'=>0])}" + '&page=' + obj.curr + '&limit=' + obj.limit + '&curr=' + obj.curr;
                    location.href = url;
                }
            }
        });
    });
</script>
{/block}